<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title></title>
    <meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" th:href="@{/Hospital/Css/bootstrap.css}" />
	<link rel="stylesheet" type="text/css" th:href="@{/Hospital/Css/bootstrap-responsive.css}" />
	<link rel="stylesheet" type="text/css" th:href="@{/Hospital/Css/style.css}" />
	<script type="text/javascript" th:src="@{/Hospital/Js/jquery.js}"></script>
	<!--<script type="text/javascript" th:src="../Js/jquery.sorted.js"></script>-->
	<script type="text/javascript" th:src="@{/Hospital/Js/bootstrap.js}"></script>
	<script type="text/javascript" th:src="@{/Hospital/Js/ckform.js}"></script>
	<script type="text/javascript" th:src="@{/Hospital/Js/common.js}"></script>
	<script th:src="@{/Hospital/layer/layer.js}"></script>

</head>
<body>
<form class="form-inline definewidth m20" method="post">
   <table>
		<tr>
			<td align="right">原密码:</td><td><input type="password" id="oldPassword"/></td>
		</tr>
		<tr>
			<td align="right">新密码:</td><td><input type="password" id="newPassword"/></td>
		</tr>
		<tr>
			<td align="right">确认密码:</td><td><input type="password" id="rePassword"/></td>
		</tr>
		<tr>
			<td colspan="2" align="center"><br/>
				<input type="button" value="更新" id="update" class="btn btn-primary"/>
			</td>
		</tr>
   </table>
</form>
</body>
</html>
<script>
	//点击更新事件
	$("#update").click(function (){
		//获取输入框参数
		let oldPassword = $("#oldPassword").val();
		let newPassword = $("#newPassword").val();
		let rePassword = $("#rePassword").val();

		if (newPassword !== rePassword){
			layer.msg("新密码和确认密码两次输入不一致！");
		}else {
			$.post("updatePassword",{oldPassword:oldPassword,newPassword:newPassword},function (data){

				layer.msg(data.msg);
				if (data.status === 1){
					//回退到登录页面
					top.location.href = "/login";
				}

			})
		}
	})

	$("#rePassword").blur(function (){
		let newPassword = $("#newPassword").val();
		let rePassword = $("#rePassword").val();

		if (newPassword !== rePassword){
			layer.msg("新密码和确认密码两次输入不一致！");
		}
	})

</script>